<template>
  <div>
    <el-form :model="formItem" label-width="120px" size="mini" class="form-view">
      <el-row :gutter="40">
        <el-col :span="12">
          <el-form-item label="周次：" prop="weekTime">
            {{ formatYearWeek(formItem.weekTime) }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="单位：" prop="unitName">
            {{ formItem.unitName }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="调研准备(%)：" prop="survey">
            {{ formItem.survey }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="上门调研(%)：" prop="dropIn">
            {{ formItem.dropIn }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="调研资料整理(%)：" prop="material">
            {{ formItem.material }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资产盘点(%)：" prop="assetInventory">
            {{ formItem.assetInventory }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资产录入(%)：" prop="assetEntry">
            {{ formItem.assetEntry }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="资产入库(%)：" prop="assetWarehousing">
            {{ formItem.assetWarehousing }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="方案定制(%)：" prop="schemeCustomization">
            {{ formItem.schemeCustomization }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="初始化健康检查(%)：" prop="healthCheckup">
            {{ formItem.healthCheckup }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="单项完成进度(%)：" prop="schedule">
            {{ formItem.schedule }}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="完工时间：" prop="closingTime">
            {{ formatDate(formItem.closingTime,'YYYY-MM-DD HH:mm:ss' ) }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="本周工作完成情况：">
            <div class="height-div">
              {{ weekDescription }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="总结描述：" prop="summaryDescription">
            <div class="height-div">
              {{ formItem.summaryDescription }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="下周工作计划：" prop="workPlan">
            <div class="height-div">
              {{ formItem.workPlan }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="问题记录及解决方案：" prop="problemLog">
            <div class="height-div">
              {{ formItem.problemLog }}
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注：" prop="remarks">
            <div class="height-div">
              {{ formItem.remarks }}
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
// 定义一个表单原始项
const formItem = {
  /** 单位名称 */
  unitName: '',
  /** 单位编码 */
  unitCode: '',
  /** 本周工作情况 */
  weekDescription: '',
  /** 调研准备 */
  survey: '',
  /** 初始化健康检查 */
  healthCheckup: '',
  /** 上门调研 */
  dropIn: '',
  /** 单项完成进度 */
  schedule: '',
  /** 调研资料整理 */
  material: '',
  /** 完工时间 */
  closingTime: '',
  /** 资产盘点 */
  assetInventory: '',
  /** 资产入库 */
  assetWarehousing: '',
  /** 资产录入 */
  assetEntry: '',
  /** 方案定制 */
  schemeCustomization: '',
  /** 总结描述 */
  summaryDescription: '',
  /** 下周工作计划 */
  workPlan: '',
  /** 问题记录及解决方案 */
  problemLog: '',
  /** 备注 */
  remarks: '',
  createTime: new Date()
}
import moment from 'moment'
import { detail } from '@neu/dcom-ui/api/transferWeekly'
// import { weekBegin, weekEnd } from '@neu/biz-core/utils/utils'
// import { list as dayList } from '@neu/dcom-ui/api/workDaily'
import { formatDate } from '@neu/biz-core/utils/utils'
// import { formatDate } from '@neu/biz-core/utils/utils'
export default {
  name: 'TransferWeeklyViewForm',
  props: {
    // 根据id可判断是新建还是更新
    id: {
      required: false,
      type: Number,
      default: -1
    }
  },
  data() {
    return {
      // 查看的表单内容
      formItem: {
        ...formItem
      },
      weekDescription: '',
      formatDate
    }
  },
  watch: {
    // 监控id的变化，初始化表单数据
    id: {
      handler: 'fetch',
      immediate: true
    }
  },
  created() {
    this.fetch()
  },
  methods: {
    // 初始化表单数据
    fetch() {
      if (this.id !== -1) {
        detail(this.id).then(response => {
          this.formItem = {
            ...response.data
          }
          // if (response.data.unitCode) {
          //   this.getDayWorkList(response.data.unitCode, this.formItem.createTime)
          // }
        })
      } else {
        this.formItem = {
          ...formItem
        }
      }
    },
    // getDayWorkList(unitCode) {
    //   const dateTime = new Date(this.formItem.createTime)
    //   this.weekDescription = ''
    //   dayList({
    //     s_unitCode: unitCode,
    //     s_afEqReportDate: weekBegin(dateTime.getTime()),
    //     s_beEqReportDate: weekEnd(dateTime.getTime())
    //   }).then(res => {
    //     res.data.forEach(item => {
    //       this.weekDescription += '日期:' + formatDate(item, 'YYYY-MM-DD') + ' ' + formatDate(item.serviceStartTime, 'HH:mm') + '至' + formatDate(item.serviceEndTime, 'HH:mm') + '  工作内容：' + item.jobContent + '\n'
    //     })
    //   })
    // },
    formatYearWeek(weekTime) {
      return moment(weekTime).year() + ' 年 ' + moment(weekTime).week() + ' 周'
    }
  }
}
</script>

<style lang="scss" scoped>
.height-div {
    min-height: 80px;
    max-height: 100px;
}
</style>
